import request from '../../../../../public/js/common/api/api.js';

const CBSUrl = Utils.CurDomain.CBSUrl;

const _ajaxOptions = {
    contentType: 'application/json',
    dataType: 'text',
    async: true,
    dataFilter(data, type) {
        return data;
    }
};

/**
 * @file领用单API
 */
export default class materialreqbillsApi {
    /**
    * 物料领用单 列表
    * @returns
    */
    static getmaterialreqList(data) {
        return request.post(`${CBSUrl}/materialreqbills/list`, data);
    }
    /**
     * 新增 物料领用单
     * @param {*} data
     * @returns
     */
    static addmaterialReq(data) {
        return request.post(`${CBSUrl}/materialreqbills`, data);
    }
    /**
    * 物料领用单 修改
    * @returns
    */
    static updatematerialreqBill(id, data) {
        return request.put(`${CBSUrl}/materialreqbills/${id}`, data);
    }

    /**
     * 物料领用单 详情
     * @param {*} id
     * @returns
     */
    static getmaterialreqBill(id) {
        return request.get(`${CBSUrl}/materialreqbills/${id}`);
    }

    /**
     * 物料领用单 删除
     * @returns
     */
    static deletematerialreqBill(id) {
        return request.delete(`${CBSUrl}/materialreqbills/${id}`);
    }


    /**
     * 批量提交与审核
     * @param {*} ids
     * @param {*} isAudit
     * @returns
     */
    static billStatusDispose(ids, status, isRollback = false) {
        let _json = {
            1: [`/submit`, 2],
            2: [`/audit`, 3]
        }
        let _jsonRoll = {
            2: [`/resubmit`, 1],
            3: [`/reaudit`, 2]
        }

        let _url = isRollback ? _jsonRoll[status][0] : _json[status][0];
        return request.put(`${CBSUrl}/materialreqbills${_url}`, ids)
    }

    /**
     * 查询批次饲料价格详情
     * @param {} mid
     * @returns
     */
    static getFeedPrices(id) {
        return request.get(`${CBSUrl}/breedbatchfeedprices/by/${id}`);
    }

    //获取公司和部门 aotype=10公司，aotype=1部门,taginfo=210筛选组织标签是猪场的
    static queryBaseOrgunitList(upoid, aotype, taginfo) {
        return request.get(`${Utils.CurDomain.SysPlfUrl}/yyorgunits/by/q?upoid=${upoid}&aotype=${aotype}&taginfo=${taginfo}`);
    }

}
